<template>
	<view>
		<!-- 扫码弹窗 -->
		<u-popup v-model="show" border-radius="20" mode="center">
			<view class="show-popup-box">
				<input type="number" class="ipt-popup" v-model="number" placeholder="请输入要核销的金额" />
				<button type="default" class="popup-btn" @click="subScanCode">确定</button>
			</view>
		</u-popup>

		<view class="header-box">
			<view class="user-box">
				<view class="user-head-img-box">
					<image :src="$wanlshop.oss(shop_info.avatar)" mode="aspectFill"></image>
				</view>
				<view class="right-user-box">
					<view class="username">{{ shop_info.shopname }}</view>
					<view class="user-id">ID: {{ shop_info.id }}</view>
					<view class="user-address">绑定城市: {{shop_info.city}}</view>
				</view>

				<view class="edit-box" @click="goToEditUserData">
					<image src="../../../static/images/shop/edit.png" mode=""></image>
					<view>编辑</view>
				</view>

				<view class="sao-code" @click="scanCode">
					<image src="../../../static/images/shop/sao.png" mode=""></image>
				</view>
			</view>
		</view>

		<view class="show-box-btm">

			<!-- 店铺概括 -->
			<!--<view class="iten-white-box one-class-box">
				<view class="label-title">店铺概括</view>
				<view class="dpgk-btm-content">
					<view class="item-dpgk">
						<view class="dpgk-money">{{ order_count }}</view>
						<view class="dpgk-name">总订单数</view>
					</view>
					 <view class="item-dpgk">
						<view class="dpgk-money">0.00</view>
						<view class="dpgk-name">总销售额</view>
					</view> 
				</view>-->
		</view>

		<!-- 今日详情 -->
		<!-- <view class="iten-white-box one-class-box">
				<view class="label-title">今日详情</view>
				<view class="jrxq-btm-content">
					<view class="item-jrxq-detail">
						<view class="jrxq-money">{{ today_order }}</view>
						<view class="jrxq-name">总订单数</view>
					</view>
					<view class="item-jrxq-detail">
						<view class="jrxq-money">{{ today_tixian }}</view>
						<view class="jrxq-name">已提取金额</view>
					</view>
					<view class="item-jrxq-detail">
						<view class="jrxq-money">{{ money }}</view>
						<view class="jrxq-name">未提取金额</view>
					</view>
				</view>
			</view> -->
		<view class="storeProfile">
			<h3>店铺概况</h3>
			<view class="storeProfileCenter">
				<view class="order-num">
					<view class="num">{{orderData.order_num}}</view>
					<view class="storeText">总订单数</view>
				</view>
				<view class="saleroom">
					<view class="num">{{orderData.total_amount}}</view>
					<view class="storeText">总销售额</view>
				</view>
			</view>
			<view class="storeProfileBottom">
				<view class="saleroom">
					<view class="num">{{orderData.Withdrawal}}</view>
					<view class="storeText">已提现金额</view>
				</view>
				<view class="saleroom">
					<view class="num">{{orderData.money}}</view>
					<view class="storeText">未提现金额</view>
				</view>
				<view class="saleroom">
					<view class="num">{{orderData.Write_off}}</view>
					<view class="storeText">已核销订单</view>
				</view>
				<view class="saleroom">
					<view class="num">{{orderData.Write_no}}</view>
					<view class="storeText">未核销订单</view>
				</view>

			</view>
		</view>
		<!-- <view class="storeOption">
			<view v-for="(item, index) in storeOptionArr" :key="item.id" @click="toPages(item)">
				<image :src="item.icon" mode="" class="storeOptionImg"></image>
				<view class="storeOptionName">
					{{item.name}}
				</view>
			</view>
		</view> -->

		<!-- 我的订单 -->
		<view class="iten-white-box">
			<view class="order-top-box" @click="goToOrder(0)">
				<view class="left-name">我的订单</view>
				<view class="right-name">
					<text>查看全部</text>
					<u-icon style="margin-left: 10rpx;" name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="order-btm-content">
				<view class="item-order" @click="goToOrder(1)">
					<view class="label-order-img-box" style="width: 61rpx;height: 51rpx;">
						<image :src="imgUrl + 'not-detected.png'" mode=""></image>
					</view>
					<view class="order-name">未核销</view>
				</view>
				<view class="item-order" @click="goToOrder(2)">
					<view class="label-order-img-box" style="width: 53rpx;height: 50rpx;">
						<image :src="imgUrl + 'consumed.png'" mode=""></image>
					</view>
					<view class="order-name">已核销</view>
				</view>
				<!-- <view class="item-order" @click="goToOrder(3)">
					<view class="label-order-img-box" style="width: 52rpx;height: 50rpx;">
						<image src="../../../static/images/shop/m3.png" mode=""></image>
					</view>
					<view class="order-name">待提货</view>
				</view>
				<view class="item-order" @click="goToOrder(4)">
					<view class="label-order-img-box" style="width: 48rpx;height: 49rpx;">
						<image src="../../../static/images/shop/m4.png" mode=""></image>
					</view>
					<view class="order-name">已完成</view>
				</view> -->
			</view>
		</view>

		<!-- 功能 -->
		<view class="iten-white-box">
			<view class="item-fer-box" v-for="(item,index) in labelArr" :key="index" @click="goToLabel(item)">
				<view class="fer-left-box">
					<text>{{ item.name }}</text>
					<image v-if="item.icon" class="img-m5" :src="item.icon" mode=""></image>
				</view>
				<u-icon color="#B6B6B6" name="arrow-right"></u-icon>
			</view>
		</view>

		<!-- 发布成功弹窗 -->
		<view class="shop-popup-box" v-show="popupType">
			<view class="success-box" :style="{ backgroundImage: 'url(' + imgUrl + '/bg-2.png'  + ')' }">

				<view class="success-name">发布成功</view>
				<view class="sub-btn" @click="popupType = !popupType">好的</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl: this.$BASE_URL_YIYUAN, // 图片路径
				popupType: false, // 发布消息成功弹窗
				show: false, // 扫码核销弹窗
				uid: 0,
				number: '', // 核销金额
				money: {}, //为体现余额
				order_count: 0, // 总订单数
				shop_info: {}, // 店铺信息
				today_order: 0, //今日订单数
				today_tixian: 0, // 今天提现金额
				orderData: {}, // 订单数据/店铺数据
				order_num: '', // 核销订单
				labelArr: [
					// {
					// 	name: '结算记录',
					// 	icon: '',
					// 	path: '/pages/user/shopadmin/mentshop'
					// },
					{
						name: '商品管理',
						icon: '',
						path: '/pages/shop/storeManage'
					},
					{
						name: '我的钱包',
						icon: '',
						path: '/pages/page/shopadmin/wallet/index'
					},
					// {
					// 	name: '好人值核销记录',
					// 	icon: '',
					// 	path: '/pages/user/writeoff/bill'
					// },
					// {
					// 	name: '发布消息',
					// 	icon: '../../../static/images/shop/m5.png',
					// 	path: '/pages/user/shopadmin/circle/release'
					// }
				],
				// storeOptionArr: [{
				// 		name: '反馈',
				// 		id: 1,
				// 		icon: this.$BASE_URL_YIYUAN + 'feedback.png',
				// 		path: ''
				// 	},
				// 	{
				// 		name: '商店管理',
				// 		id: 2,
				// 		icon: this.$BASE_URL_YIYUAN + 'store-manage.png',
				// 		path: '/pages/shop/storeManage'
				// 	},
				// 	{
				// 		name: '设置',
				// 		id: 3,
				// 		icon: this.$BASE_URL_YIYUAN + 'setting.png',
				// 		path: ''
				// 	},
				// ]
			}
		},
		onLoad() {
			
			
		},
		onShow() {
			this.init()
			this.orderInit()
		},
		methods: {
			toPages(item){
				uni.navigateTo({
					url:item.path
				})
			},
			//初始化店铺统计
			init() {
				this.$api.post({
					url: '/wanlshop.shop/shopStatistical',
					success: res => {
						for (let i in res) this[i] = res[i];
						uni.setStorageSync('userShopId', res.shop_info.id)
					}
				})
			},
			// 订单数据
			orderInit(){
				this.$api.post({
					url: "/wanlshop.shop/shopInfo",
					success: res => {
						this.orderData = res
					}
				})
			},

			goToLabel(item) {
				uni.navigateTo({
					url: item.path
				})
			},

			//我的订单
			goToOrder(tab) {
				console.log(tab)
				uni.navigateTo({
					url: `/pages/page/shopadmin/order?tab=${tab}`
				})
			},

			//编辑个人资料
			goToEditUserData() {
				uni.navigateTo({
					url: "/pages/page/shopadmin/editdata"
				})
			},

			//扫码
			scanCode() {
				wx.scanCode({
					success: res => {
						this.order_num = res.result;
						// this.uid = uid;
						this.show = true
					}
				})
			},
			// 提交扫码结果
			subScanCode() {
				let {
					uid,
					number
				} = this;
				let shop_id = this.shop_info.id;
				this.$api.post({
					url: '/wanlshop.shop/writtOff',
					data: {
						// uid,
						// shop_id,
						// number
						order_no: this.order_num
					},
					success: res => {
						this.show = false
						if (res == null) {
							uni.showToast({
								title: '核销成功',
								icon: 'success',
								duration: 1000
							})
						}
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.header-box {
		background-color: #FD8464;
		width: 100%;
		height: 250rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		padding-top: 40rpx;
	}

	.user-box {
		width: 100%;
		display: flex;
		align-items: center;
		position: relative;
	}

	.user-head-img-box {
		width: 140rpx;
		height: 140rpx;
		border-radius: 50%;
		overflow: hidden;
		flex-shrink: 0;
		margin-right: 30rpx;
	}

	.user-head-img-box image {
		width: 100%;
		height: 100%;
	}

	.right-user-box {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.username {
		font-size: 38rpx;
		line-height: 38rpx;
		font-weight: bold;
		color: white;
		margin-bottom: 15rpx;
	}

	.user-id {
		font-size: 26rpx;
		color: white;
		line-height: 26rpx;
		margin-bottom: 15rpx;
	}

	.user-address {
		color: white;
		font-size: 26rpx;
	}

	.shop-admin-map {
		font-size: 26rpx;
		color: white;
		line-height: 26rpx;
	}

	.edit-box {
		display: flex;
		font-size: 24rpx;
		color: #FFFFFF;
		align-items: center;
		position: absolute;
		right: 0;
		top: 15rpx;
	}

	.edit-box image {
		width: 21rpx;
		height: 24rpx;
		margin-right: 10rpx;
	}

	.sao-code {
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		right: 0;
		top: 55rpx;
	}

	.sao-code image {
		width: 100%;
		height: 100%;
	}

	.show-box-btm {
		width: 100%;
		position: relative;
		top: -30rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
		background-color: #F5F5F5;
	}

	.iten-white-box {
		width: 686rpx;
		background: white;
		border-radius: 10rpx;
		margin: 21rpx auto 30rpx;
	}

	.storeProfile {
		width: 686rpx;
		// height: 390rpx;
		margin: -30rpx auto 0;
		background-color: #FFFFFF;
		padding-top: 29rpx;
		border-radius: 10rpx;

		h3 {
			color: #000000;
			font-size: 32rpx;
			font-family: PingFang;
			font-weight: bold;
			text-align: center;
		}

		.storeProfileCenter {
			display: flex;
			justify-content: space-between;
			margin-top: 66rpx;

			&>view {
				width: 50%;
				display: flex;
				flex-direction: column;

				view {
					text-align: center;
				}

				.num {
					font-size: 34rpx;
					font-family: PingFang;
					font-weight: bold;
					color: #FF572B;
					margin-bottom: 34rpx;
				}

				.storeText {
					font-size: 24rpx;
					font-family: PingFang;
					font-weight: 500;
					color: #999999;
				}
			}
		}

		.storeProfileBottom {
			display: flex;
			justify-content: space-between;
			border-top: 1px solid #EEEEEE;
			margin-top: 37rpx;
			padding: 30rpx 18rpx;

			.num {
				font-size: 34rpx;
				font-family: Adobe Heiti Std;
				font-weight: normal;
				color: #000000;
				text-align: center;
			}

			.storeText {
				font-size: 24rpx;
				font-family: Adobe Heiti Std;
				font-weight: normal;
				color: #999999;
				text-align: center;
				margin-top: 34rpx;
			}
		}
	}

	.storeOption {
		width: 686rpx;
		margin: 22rpx auto;
		display: flex;
		justify-content: space-between;
		background: #FFFFFF;
		border-radius: 10px;
		padding: 28rpx 14rpx 31rpx 12rpx;

		&>view {
			flex: 1;
			display: flex;
			justify-content: center;
			flex-direction: column;
			.storeOptionImg {
				width: 60rpx;
				height: 60rpx;
				margin: 0 auto;
			}

			.storeOptionName {
				font-size: 25rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333333;
				text-align: center;
				margin-top: 7rpx;
			}

		}

	}

	.label-title {
		text-align: center;
		font-size: 32rpx;
		font-weight: bold;
		padding: 30rpx 0;
	}

	.dpgk-btm-content {
		width: 100%;
		padding: 35rpx 160rpx 50rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
	}

	.item-dpgk {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.item-dpgk .dpgk-money {
		font-size: 34rpx;
		color: #FF572B;
		font-weight: bold;
		line-height: 34rpx;
	}

	.item-dpgk .dpgk-name {
		font-size: 24rpx;
		color: #999999;
		margin-top: 34rpx;
	}

	.jrxq-btm-content {
		width: 100%;
		padding: 17rpx 0 29rpx 0;
		display: flex;
	}

	.item-jrxq-detail {
		display: flex;
		flex-direction: column;
		flex-shrink: 0;
		flex: 1;
		align-items: center;
	}

	.jrxq-money {
		font-size: 34rpx;
		font-weight: bold;
	}

	.jrxq-name {
		font-size: 25rpx;
		color: #333333;
		margin-top: 20rpx;
	}

	.order-top-box {
		width: 100%;
		padding: 30rpx;
		box-sizing: border-box;
		border-bottom: solid 2rpx #F6F6F6;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.left-name {
		font-size: 30rpx;
		color: #000;
	}

	.right-name {
		font-size: 26rpx;
		line-height: 26rpx;
		color: #999999;
		display: flex;
		align-items: center;
	}

	.order-btm-content {
		width: 686rpx;
		display: flex;
		padding: 30rpx 48rpx 35rpx 48rpx;
	}

	.item-order {
		display: flex;
		flex-direction: column;
		// flex-shrink: 0;
		align-items: center;
		margin-right: 90rpx;
	}

	.label-order-img-box {
		width: 61rpx;
		height: 51rpx;
	}

	.label-order-img-box image {
		width: 100%;
		height: 100%;
	}

	.item-order .order-name {
		font-size: 25rpx;
		color: #333333;
		margin-top: 20rpx;
	}

	.item-fer-box {
		// border-bottom: solid 1rpx #EBEBEB;
		padding: 35rpx 25rpx;
		box-sizing: border-box;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.fer-left-box {
		font-size: 30rpx;
		font-weight: 500;
		line-height: 30rpx;
		display: flex;
		align-items: center;
	}

	.fer-left-box .img-m5 {
		width: 23rpx;
		height: 28rpx;
		margin-left: 10rpx;
	}

	.show-popup-box {
		width: 540rpx;
		height: 300rpx;
		border-radius: 20rpx;
		padding: 30rpx 25rpx;
		box-sizing: border-box;
	}

	.ipt-popup {
		width: 100%;
		height: 50rpx;
		border: solid 1rpx #F1F1F1;
		padding: 10rpx 15rpx;
		box-sizing: border-box;
		margin-top: 70rpx;
	}

	.popup-btn {
		width: 235rpx;
		height: 60rpx;
		background-color: #3199FF;
		font-size: 26rpx;
		border-radius: 30rpx;
		color: white;
		margin-top: 50rpx;
	}

	.shop-popup-box {
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		background: rgba(0, 0, 0, .6);
		z-index: 999;
	}

	.success-box {
		width: 470rpx;
		height: 420rpx;
		background-color: white;
		background-image: url();
		background-size: 100% 100%;
		background-repeat: no-repeat;
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		top: 25%;
		border-radius: 40rpx;
		padding: 300rpx 58rpx 0;
		box-sizing: border-box;
	}

	.success-name {
		width: 100%;
		font-size: 36rpx;
		color: #FFFFFF;
		font-weight: bold;
		position: absolute;
		top: 30rpx;
		text-align: center;
		left: 0;
	}

	.success-desc {
		display: flex;
		flex-direction: column;
		padding: 25rpx 82rpx;
		border-bottom: solid 1rpx #D6D6D6;
		font-size: 27rpx;
		color: #131313;
		font-weight: 500;
	}

	.sub-btn {
		width: 235rpx;
		height: 60rpx;
		background: #3199FF;
		box-shadow: 0px 8rpx 12rpx 6rpx rgba(0, 101, 196, 0.16);
		border-radius: 29rpx;
		font-size: 23rpx;
		color: white;
		font-weight: 500;
		margin: 27rpx auto;
		display: flex;
		align-items: center;
		justify-content: center;

	}
</style>
